package org.ihelpuoo.weboo.tag.core;

import java.io.IOException;

import javax.servlet.jsp.JspException;

import org.ihelpuoo.weboo.exception.ModuleNotFoundException;
import org.ihelpuoo.weboo.module.Module;
import org.ihelpuoo.weboo.tag.WebooTag;

public class MessageTag extends WebooTag
{

	private static final long	serialVersionUID	= 690515352427406164L;

	private String				module;
	private String				key;

	public String getModule()
	{
		return module;
	}

	public void setModule(String module)
	{
		this.module = module;
	}

	public String getKey()
	{
		return key;
	}

	public void setKey(String key)
	{
		this.key = key;
	}

	@Override
	public void end() throws JspException
	{
		try
		{
			Module m = getModule(module);
			pageContext.getOut().write(m.getModuleContext().getMessage(getLocale(),key));
		}
		catch (ModuleNotFoundException e)
		{
			throw new JspException(e);
		}
		catch (IOException e)
		{
			throw new JspException(e);
		}
	}

	@Override
	protected void start() throws JspException
	{
	}
}
